﻿using System;
using System.Text;
using System.Collections.Generic;

namespace Vbyte.SharpOrm.SqlDb
{
    /// <summary>
    /// 数据过滤器、SQL数据筛选设置
    /// </summary>
    public interface  ISqlConstrains
    {
        /// <summary>
        /// where条件限制集合
        /// </summary>
        /// <returns></returns>
        string[] GetConditions();

        /// <summary>
        /// Group By 字段集合
        /// </summary>
        /// <returns></returns>
        string[] GetGroupByConfig();

        /// <summary>
        /// 获取自定义列集合
        /// </summary>
        /// <returns></returns>
        List<string> GetCustomFieldList();

        /// <summary>
        /// 获取自定义值集合
        /// </summary>
        /// <returns></returns>
        List<string> GetCustomValueList();

        /// <summary>
        /// 添加AND关系的条件限制(原生SQL)
        /// </summary>
        /// <param name="sqlCondition">条件限制语句</param>
        /// <returns>应用了限制之后的过滤筛选器</returns>
        ISqlConstrains NativeCondition(string sqlCondition);

        /// <summary>
        /// 添加OR关系的条件限制(原生SQL)
        /// </summary>
        /// <param name="sqlCondition">条件限制语句</param>
        /// <returns>应用了限制之后的过滤筛选器</returns>
        ISqlConstrains OrNativeCondition(string sqlCondition);

        /// <summary>
        /// 添加AND ()关系的条件限制(原生SQL)
        /// </summary>
        /// <param name="sqlCondition">条件限制语句</param>
        /// <returns>应用了限制之后的过滤筛选器</returns>
        ISqlConstrains WrapCondition(string sqlCondition);

        /// <summary>
        /// 添加OR ()关系的条件限制(原生SQL)
        /// </summary>
        /// <param name="sqlCondition">条件限制语句</param>
        /// <returns>应用了限制之后的过滤筛选器</returns>
        ISqlConstrains OrWrapCondition(string sqlCondition);

        /// <summary>
        /// 获取自定义的Group By 原生字段分组排序
        /// </summary>
        /// <param name="sqlGroupByFields">Group By 原生字段</param>
        /// <returns>应用了Group By 之后的过滤筛选器</returns>
        ISqlConstrains GroupByFields(string sqlGroupByFields);

        /// <summary>
        /// 限制某属性（字段）必须在集合中
        /// </summary>
        /// <typeparam name="T">集合类型</typeparam>
        /// <param name="propName">属性(字段)名称</param>
        /// <param name="array">值集合</param>
        /// <returns>应用了在集合中规则的过滤筛选器</returns>
        ISqlConstrains In<T>(string propName, T[] array) where T : IConvertible;

        /// <summary>
        /// 限制某属性（字段）必须在查询集合中
        /// </summary>
        /// <param name="propName">属性(字段)名称</param>
        /// <param name="nativeSqlCollection">查询集合</param>
        /// <returns>应用了在集合中规则的过滤筛选器</returns>
        ISqlConstrains In(string propName, string nativeSqlCollection);

        /// <summary>
        /// 限制某属性（字段）必须不在集合中
        /// </summary>
        /// <typeparam name="T">集合类型</typeparam>
        /// <param name="propName">属性(字段)名称</param>
        /// <param name="array">值集合</param>
        /// <returns>应用了不在集合中规则的过滤筛选器</returns>
        ISqlConstrains NotIn<T>(string propName, T[] array) where T : IConvertible;

        /// <summary>
        /// 限制某属性（字段）必须不在查询集合中
        /// </summary>
        /// <param name="propName">属性(字段)名称</param>
        /// <param name="nativeSqlCollection">查询集合</param>
        /// <returns>应用了不在集合中规则的过滤筛选器</returns>
        ISqlConstrains NotIn(string propName, string nativeSqlCollection);

        /// <summary>
        /// 添加自定义字段的名称(语句定义）和相匹配的值
        /// </summary>
        /// <param name="fieldName">字段名称</param>
        /// <param name="fieldValue">字段值</param>
        /// <returns>应用了定义字段规则的过滤筛选器</returns>
        ISqlConstrains WithCustomField(string fieldName, string fieldValue);

    }
}
